Skip to content

Added a fallback image property to ImageBrushLoader#41

Merged
SKProCH merged 3 commits intoAvaloniaUtils:masterfrom
TemuWolverine:master
Mar 2, 2026
Merged

Added a fallback image property to ImageBrushLoader#41
SKProCH merged 3 commits intoAvaloniaUtils:masterfrom
TemuWolverine:master

Conversation

@TemuWolverine
Copy link
Copy Markdown
Contributor

Just like in my previous commit, this adds a fallback image property, this time to ImageBrushLoader

Example usage

            <Ellipse Width="125" Height="125">
                <Ellipse.Fill>
                    <ImageBrush 
asyncImageLoader:ImageBrushLoader.FallbackImage="{x:Static app:App.FallbackImage}" 
asyncImageLoader:ImageBrushLoader.Source="{Binding Path=ArtistThumb" />
                </Ellipse.Fill>
            </Ellipse>
    private static Bitmap? fallbackImage;
    public static Bitmap FallbackImage
    {
        get
        {
            return fallbackImage ??= new Bitmap(AssetLoader.Open(new Uri("avares://WateryTart.Core/Assets/cover_dark.png")));
        }
    }

Appearance (yes I know its the wrong fallback image but thats between me and my poor asset management 😅)
image

@@ -27,6 +27,14 @@ private static async void OnSourceChanged(ImageBrush imageBrush, AvaloniaPropert
try {
if (!string.IsNullOrWhiteSpace(newValue)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we need to check on null there, since it checked to null in AdvancedImage, lets standardize that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that on line 31/32? AdvancedImage is an instance so its easier to check for null FallbackImage.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, the AdvancedImage has the same logic, i'm just dumb

Copy link
Copy Markdown
Contributor Author

@TemuWolverine TemuWolverine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XmlDoc added, simplified bitmap assignment & check for null
(I think I'm using this correctly, I've never used the review function)

@@ -27,6 +27,14 @@ private static async void OnSourceChanged(ImageBrush imageBrush, AvaloniaPropert
try {
if (!string.IsNullOrWhiteSpace(newValue)) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that on line 31/32? AdvancedImage is an instance so its easier to check for null FallbackImage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants